<template>
	<view>
		<view v-if="orders" style="padding-bottom: 150rpx;">
			<u-card v-for="item in orders.depositPayList" box-shadow="10rpx 10rpx 10rpx #c8c9cc" :show-head="false">
				<view class="" slot="body" style="color: #909399;">
					<view class="myCellGroup">
						<view v-if="parseFloat(item.deposit_amont).toFixed(2)>0">
							<view>押金金额</view>
							<view>{{item.deposit_amont}}</view>
						</view>
						<view v-if="parseFloat(item.deposit_pay_amont).toFixed(2)>0">
							<view>授权金额</view>
							<view>{{item.deposit_pay_amont}}</view>
						</view>
						<view v-if="parseFloat(item.deposit_total_back_amont).toFixed(2)>0">
							<view>退还金额</view>
							<view>{{item.deposit_total_back_amont}}</view>
						</view>
						<view v-if="parseFloat(item.cur_pay_blance_amont).toFixed(2)>0">
							<view>授权余额</view>
							<view>{{item.cur_pay_blance_amont}}</view>
						</view>
						<view v-if="parseFloat(item.active_blance_amont).toFixed(2)>0">
							<view>可用余额</view>
							<view>{{item.active_blance_amont}}</view>
						</view>
						<view v-if="parseFloat(item.deposit_deduction_amont).toFixed(2)>0">
							<view>扣款金额</view>
							<view>{{item.deposit_deduction_amont}}</view>
						</view>
						<view v-if="parseFloat(item.deduction_request_amont).toFixed(2)>0">
							<view>扣款中金额</view>
							<view>{{item.deduction_request_amont}}</view>
						</view>
						<view>
							<view>缴纳方式</view>
							<view>
								<text v-if="item.deposit_pay_type==1">支付宝芝麻信用预授权</text>
								<text v-if="item.deposit_pay_type==2">信用卡预授权</text>
							</view>
						</view>
						<view>
							<view>押金状态</view>
							<view>
								<text v-if="item.deposit_state==1">待缴纳</text>
								<text v-if="item.deposit_state==2">进行中</text>
								<text v-if="item.deposit_state==3">扣款中</text>
								<text v-if="item.deposit_state==4">已结束</text>
							</view>
						</view>
					</view>
					<view style="display: flex;justify-content: space-between;">
						<text>操作：</text>
						<view style="display: flex;justify-content: space-around;">
							<text style="color: #2979ff;" v-if="parseFloat(item.active_blance_amont).toFixed(2)>0.00" @click="toDeductionPage(item)">扣款</text>
							<text style="color: #2979ff;margin-left: 30rpx;" v-if="parseFloat(item.active_blance_amont).toFixed(2)>0.00">退还</text>
							<text style="color: #2979ff;margin-left: 30rpx;" v-if="item.deposit_pay_type==1&&item.deposit_state==1" @click="toQrCodeShow(item.deposit_pay_id)">显示二维码</text>
							<text style="color: #2979ff;margin-left: 30rpx;" v-if="item.deposit_pay_type==1&&item.deposit_state==1" @click="deleteItem(item.deposit_pay_id)">删除</text>
						</view>
					</view>
				</view>
				<view class="" slot="foot" style="display: flex;justify-content: space-between;">
					<view>{{item.employe_name}}</view>
					<view>{{item.step_name}}</view>
					<view>{{$u.timeFormat(item.add_datetime, 'mm月dd日 hh:MM')}}</view>
				</view>
			</u-card>
		</view>
		<view style="position: fixed;width: 100%;bottom: 0rpx;padding: 0;z-index: 999;">
			<u-button type="primary" @click="toPage('addDeposit')">添加押金</u-button>
		</view>
		<u-toast ref="uToast"></u-toast>
		<myModal ref="myModal"></myModal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				payTypeList: [{
						id: 1,
						label: '微信',
						value: 1
					},
					{
						id: 2,
						label: '支付宝',
						value: 2
					},
					{
						id: 3,
						label: '银行转账',
						value: 3
					},
					{
						id: 4,
						label: '刷卡',
						value: 4
					},
					{
						id: 5,
						label: '押金转支付',
						value: 5
					},
					{
						id: 6,
						label: '现金',
						value: 6
					}
				],
				showSelectChannel: false,
				orders: null,
				rules: {
					deposit_pay_type: [{
						required: true,
						message: '请选择支付方式',
						trigger: ['blur', 'change']
					}]
				}
			}
		},
		onLoad(options) {
			var that=this;
			if (options.data) {
				this.orders = JSON.parse(decodeURIComponent(options.data));
			}
			uni.$on('getOrdersInfo', function(data) {
				console.log("监听到了，啦啦啦");
				that.getOrderInfo();
			})
		},
		methods: {
			toDeductionPage(item){
				var page=item.deposit_pay_type==1?'depositDeductionReuest':'depositDeduction';
				console.log(page);
				uni.navigateTo({
					url: '/pages/'+page+'/'+page+'?item=' + JSON.stringify(item)
				})
			},
			toPage(e) {
				uni.navigateTo({
					url: '/pages/' + e + '/' + e + '?data=' + encodeURIComponent(JSON.stringify(this.orders)),
					complete(res) {
						console.log(res);
					}
					
				})
			},
			toQrCodeShow(deposit_pay_id) {
				uni.navigateTo({
					url: '/pages/depositQrCodeShow/depositQrCodeShow?deposit_pay_id=' + deposit_pay_id
				})
			},
			getOrderInfo() {
				var that = this;
				that.$http.get('/orders/queryById?orders_id=' + this.orders.orders_id, {}, (res) => {
					if (res.data.success) {
						that.orders = res.data.result;
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
			deleteItem(deposit_pay_id) {
				var that = this;
				that.$http.get('/depositPay/deleteById?deposit_pay_id=' + deposit_pay_id, {}, (res) => {
					if (res.data.success) {
						that.getOrderInfo();
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
		},
		onReady() {
			// this.$refs.addForm.setRules(this.rules);
		}
	}
</script>

<style>
.myCellGroup>view {
		display: flex;
		justify-content: space-between;
		padding: 10rpx 0;
		border-bottom: solid #F8F8F8 1px;
	}
</style>